import 'package:flutter/material.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';

class FeedbackQuestionCategoryView extends StatefulWidget {
  final Function(String category)? choseCategory;
  const FeedbackQuestionCategoryView({super.key, this.choseCategory});

  @override
  State<FeedbackQuestionCategoryView> createState() => _FeedbackQuestionCategoryViewState();
}

class _FeedbackQuestionCategoryViewState extends State<FeedbackQuestionCategoryView> {
  final dataSource = ['账号问题', '影视资源', 'APP体验', '播放失败', '播放卡顿', '分类有误', '充值问题', '其他'];
  String? selectCategory;
  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      shrinkWrap: true,
      physics: NeverScrollableScrollPhysics(),
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 4, mainAxisSpacing: 12, crossAxisSpacing: 5, childAspectRatio: 84 / 34),
      itemCount: dataSource.length,
      itemBuilder: (BuildContext context, int index) {
        final category = dataSource[index];
        final select = category == selectCategory;
        return GestureDetector(
          onTap: () {
            selectCategory = category;
            setState(() {});
            widget.choseCategory?.call(category);
          },
          child: Container(
            decoration: BoxDecoration(
              color: select ? Color(0xFFE1351F) : Colors.white.withOpacity(.05),
              borderRadius: BorderRadius.circular(3),
            ),
            alignment: Alignment.center,
            child: Text(
              category,
              style: TextStyle(color: Colors.white, fontSize: 12),
            ),
          ),
        );
      },
    );
  }
}

class InfomationInputView extends StatefulWidget {
  final String title;
  final String hint;
  final TextEditingController controller;
  const InfomationInputView(this.controller, {super.key, this.title = '', this.hint = ''});

  @override
  State<InfomationInputView> createState() => _InfomationInputViewState();
}

class _InfomationInputViewState extends State<InfomationInputView> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        12.sizeBoxH,
        Row(
          children: [
            SizedBox(
              width: 90,
              child: Text(
                widget.title,
                style: TextStyle(color: Colors.white.withOpacity(0.9), fontSize: 14, fontWeight: FontWeight.w500),
              ),
            ),
            Expanded(
              child: TextField(
                maxLines: null,
                style: TextStyle(color: Colors.white, fontSize: 12),
                maxLength: 20,
                controller: widget.controller,
                decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: widget.hint,
                    hintStyle: TextStyle(color: Color(0xff525252), fontSize: 12),
                    counterText: '',
                    contentPadding: EdgeInsets.zero,
                    isDense: true),
              ),
            )
          ],
        ),
        12.sizeBoxH,
        Divider(
          height: 0.5,
          color: Colors.black.withOpacity(0.05),
        )
      ],
    );
  }
}
